package cn.ichiva.luckysheet;

import cn.ichiva.luckysheet.utils.LuckySheetDb;
import lombok.extern.slf4j.Slf4j;

import org.iq80.leveldb.Options;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

@Slf4j
@Configuration
public class LuckySheetConfig {

    @Value("${db.path:./data}")
    String dbPath;

    //启动ws服务
    @Bean
    public ServerEndpointExporter getWebSocketServer() throws Exception {
        return new ServerEndpointExporter();
    }

    //为了简化部署,这里使用嵌入式kv数据库
    @Bean
    public LuckySheetDb getLuckySheetDb() throws IOException {
        return new LuckySheetDb(dbPath);
    }
}
